//
//  Image.cpp
//  Prism
//
//  Created by Bas du Pre on 20-05-11.
//  Copyright 2011 UU. All rights reserved.
//

#include "graphics/Texture.h"

using namespace Prism;
using namespace Prism::Graphics;

Texture::Texture() {
    myFile = false;
    native_init();
    _antiAlias = true;
}

Texture::Texture(String filename) {
    load(filename);
    native_init();
    _antiAlias = true;
}

Texture::Texture(File *file) {
    this->_file = file;
    myFile = false;
    native_init();
    _antiAlias = true;
}

Texture::Texture(File &file) {
    this->_file = &file;
    myFile = false;
    native_init();
    _antiAlias = true;
}

Texture::~Texture() {
    native_deInit();
    if (myFile)
        delete _file;
}

void Texture::load(File &file) {
    this->_file = &file;
    myFile = false;
}

void Texture::load(File *file) {
    this->_file = file;
    myFile = false;
}

void Texture::load(String filename) {
    load(new File(filename));
    myFile = true;
}

File *Texture::file() {
    return _file;
}

String Texture::toString() {
    String basename = _file->basename();
    return String::fromFormat("[Texture file=\"%_\"]", &basename);
}

Prism::Size Texture::size() {
    return this->native_size();
}

void Texture::setAntiAlias(bool antiAlias) {
    _antiAlias = antiAlias;
    native_setAntiAlias(antiAlias);
}

bool Texture::antiAlias() {
    return _antiAlias;
}
